<extend name="Public:base"/>

<block name="main">
<style type="text/css">
.tab-content{padding-top: 5px;}
.nav>li>a {padding: 6px 10px;}
</style>
<div id="yzh-content" class="col-xs-12">
    <div class="main-title">
        <h2>管理员信息</h2>
    </div>


    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation" class="active"><a href="#home" role="tab" data-toggle="tab">管理员信息设置</a></li>
        <li role="presentation"><a href="#user" role="tab" data-toggle="tab">修改密码</a></li>
    </ul>
    <!-- Tab panes -->
    <div class="tab-content">
        <div role="tabpanel" class="tab-pane active" id="home">
        <form id="myform1" class="form-horizontal" action="{:U('Index/profile')}" method="post">
            <div class="form-group">
                <label class="control-label col-md-2">{:L('username')}</label>
                 <div class="col-md-5">
                     <input type="text" value="{$vo.username}" class="form-control" disabled/>
                 </div>
            </div>
           <div class="form-group">
                <label class="control-label col-md-2">{:L('email')}</label>
                <div class="col-md-5">
                <input type="text" class="form-control" name="email" value="{$vo.email}" validate="required:true,email:true,remote: '{:U('Login/checkEmail?userid='.$_SESSION['userid'])}' , minlength:1, maxlength:40"><em>(用于找回密码)</em>
                </div>
            </div>
            <div class="form-actions">
                <input type="hidden" name="id" value="{$vo.id}"/>
                <input type="submit" name="dosubmit"  value="{:L('dosubmit')}" class="btn btn-sm btn-primary" />
                <input type="hidden" name="dosubmit" value="1" />
                <input type="reset" value="{:L('cancel')}" class="btn btn-sm btn-primary"/>
            </div>
        </form>
    </div>

    <div role="tabpanel" class="tab-pane" id="user">
    <form id="myform2" class="form-horizontal" method="post" action="{:U('index/password')}">
        <div class="form-group">
            <label class="control-label col-md-2">{:L('oldpassword')}</label>
            <div class="col-md-5"><input type="password" class="form-control" name="oldpassword"></div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2">{:L('newpassword')}</label>
            <div class="col-md-5"><input type="password" class="form-control"  name="password" id="password" ></div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2">{:L('repassword')}</label>
            <div class="col-md-5"><input type="password" class="form-control"  name="repassword"></div>
        </div>
        <div class="form-actions">
            <input type="submit" class="btn btn-sm btn-primary" value="提交"/>
            <input type="reset" class="btn btn-sm btn-primary" value="取消"/>
        </div>
    </form>
</div>


<script type="text/javascript">
$(document).ready(function() {
    $('#myform1').ajaxForm({
        success:  complete,  // post-submit callback
        dataType: 'json'
    });
    $('#myform2').ajaxForm({
        success:  complete,  // post-submit callback
        dataType: 'json'
    });
});

function complete(data){
    if(data.status==1){
        $.scojs_message('修改成功', $.scojs_message.TYPE_OK);
        setTimeout(function(){  
            window.location.href = '{:U("Index/profile")}';
        },1000);
    }else{
        $.scojs_message(data.info, $.scojs_message.TYPE_ERROR);
    }

}
</script>

    <div class="tab-content">
        <div role="tabpanel" class="tab-pane" id="user">
        <form id="myform1" class="form-horizontal" action="{:U('Index/profile')}" method="post">
            <div class="form-group">
                <label class="control-label col-md-2">{:L('username')}</label>
                 <div class="col-md-5">
                     <input type="text" value="{$vo.username}" class="form-control" disabled/>
                 </div>
            </div>
           <div class="form-group">
                <label class="control-label col-md-2">{:L('email')}</label>
                <div class="col-md-5">
                <input type="text" class="form-control" name="email" value="{$vo.email}" validate="required:true,email:true,remote: '{:U('Login/checkEmail?userid='.$_SESSION['userid'])}' , minlength:1, maxlength:40"><em>(用于找回密码)</em>
                </div>
            </div>
            <div class="form-actions">
                <input type="hidden" name="id" value="{$vo.id}"/>
                <input type="submit" name="dosubmit"  value="{:L('dosubmit')}" class="btn btn-sm btn-primary" />
                <input type="hidden" name="dosubmit" value="1" />
                <input type="reset" value="{:L('cancel')}" class="btn btn-sm btn-primary"/>
            </div>
        </form>
    </div>

    <div role="tabpanel" class="tab-pane" id="user">
    <form id="myform2" class="form-horizontal" method="post" action="{:U('index/password')}">
        <div class="form-group">
            <label class="control-label col-md-2">{:L('oldpassword')}</label>
            <div class="col-md-5"><input type="password" class="form-control" name="oldpassword"></div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2">{:L('newpassword')}</label>
            <div class="col-md-5"><input type="password" class="form-control"  name="password" id="password" ></div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2">{:L('repassword')}</label>
            <div class="col-md-5"><input type="password" class="form-control"  name="repassword"></div>
        </div>
        <div class="form-actions">
            <input type="submit" class="btn btn-sm btn-primary" value="提交"/>
            <input type="reset" class="btn btn-sm btn-primary" value="取消"/>
        </div>
    </form>
</div>


<script type="text/javascript">
$(document).ready(function() {
    $('#myform1').ajaxForm({
        success:  complete,  // post-submit callback
        dataType: 'json'
    });
    $('#myform2').ajaxForm({
        success:  complete,  // post-submit callback
        dataType: 'json'
    });
});

function complete(data){
    if(data.status==1){
        $.scojs_message('修改成功', $.scojs_message.TYPE_OK);
        setTimeout(function(){
            window.location.href = '{:U("Index/profile")}';
        },1000);
    }else{
        $.scojs_message(data.info, $.scojs_message.TYPE_ERROR);
    }

}
</script>



</block>